//
//  FKIncomeDetailFooter.m
//  WanTao
//
//  Created by Macbook Pro on 2019/3/29.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKIncomeDetailFooter.h"
#import "FKIncomeDetail.h"

@interface FKIncomeDetailFooter ()

@property (nonatomic, weak) UILabel *tagLabel;
@property (nonatomic, weak) UILabel *priceLabel;
@property (nonatomic, weak) UILabel *commissionLabel;
@property (nonatomic, weak) UILabel *dateLabel;
@property (nonatomic, weak) UILabel *orderNoLabel;
@property (nonatomic, weak) UILabel *statusLabel;

@property (nonatomic, strong) UIImageView *wechat_avator;
@property (nonatomic, strong) UILabel *wechat_nickname;
@property (nonatomic, strong) UILabel *nickname;
@property (nonatomic, strong) UILabel *phone;

@end

@implementation FKIncomeDetailFooter

- (void)setupSubviews
{
    [super setupSubviews];
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    UILabel *priceLabel = [UILabel fk_labelWithFont:fk_adjustFont(16) textColor:fkMainColor];
    [self.contentView addSubview:priceLabel];
    self.priceLabel = priceLabel;
    
    UILabel *commissionLabel = [UILabel fk_labelWithFont:fk_adjustFont(12) textColor:fkMainColor];
    [self.contentView addSubview:commissionLabel];
    self.commissionLabel = commissionLabel;
    
    UILabel *dateLabel = [UILabel fk_labelWithFont:fk_adjustFont(11) textColor:fkColor999999];
    [self.contentView addSubview:dateLabel];
    self.dateLabel = dateLabel;
    
    UILabel *orderNoLabel = [UILabel fk_labelWithFont:fk_adjustFont(11) textColor:fkColor999999];
    [self.contentView addSubview:orderNoLabel];
    self.orderNoLabel = orderNoLabel;
    
    UILabel *tagLabel = [UILabel fk_labelWithFont:fk_adjustFont(13) textColor:fkMainColor textAlignment:NSTextAlignmentCenter];
    [self.contentView addSubview:tagLabel];
    self.tagLabel = tagLabel;
    [tagLabel fk_viewCornerRadius:2 borderWidth:0.8 borderColor:fkMainColor];
    
    UILabel *statusLabel = [UILabel fk_labelWithFont:fk_adjustFont(11) textColor:[UIColor whiteColor] textAlignment:NSTextAlignmentCenter];
    [self.contentView addSubview:statusLabel];
    self.statusLabel = statusLabel;
    
    [priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(12);
        make.top.offset(fk_adjustW(10));
        make.height.offset(fk_adjustW(20));
    }];
    [commissionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-12);
        make.centerY.equalTo(priceLabel);
    }];
    [dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(priceLabel);
        make.top.equalTo(priceLabel.mas_bottom).offset(fk_adjustW(10));
        make.height.offset(fk_adjustW(13.50f));
    }];
    [orderNoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(dateLabel);
        make.top.equalTo(dateLabel.mas_bottom).offset(fk_adjustW(10));
        make.height.offset(fk_adjustW(13.50f));
    }];
    [tagLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(32);
        make.height.mas_equalTo(16);
        make.centerY.equalTo(orderNoLabel);
        make.left.equalTo(orderNoLabel.mas_right).offset(8);
    }];
    [statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(fk_adjustW(46));
        make.height.mas_equalTo(fk_adjustW(15));
        make.right.equalTo(commissionLabel);
        make.centerY.equalTo(orderNoLabel);
    }];
//    fk_adjustW(10 + 20 + 10 + 13.5 + 10 + 15);
    // 新增
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = [UIColor fk_colorWithHexString:@"#dedede"];
    [self.contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(statusLabel.mas_bottom).offset(fk_adjustW(15));
        make.left.offset(12);
        make.right.offset(-12);
        make.height.offset(1);
    }];

    self.wechat_avator = [[UIImageView alloc] init];
    self.wechat_avator.layer.masksToBounds = YES;
    self.wechat_avator.layer.cornerRadius = fk_adjustW(16);
    [self.contentView addSubview:self.wechat_avator];

    [self.wechat_avator mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.width.offset(fk_adjustW(32));
        make.top.mas_equalTo(line.mas_bottom).offset(fk_adjustW(14));
        make.left.mas_equalTo(line);
    }];
    
    self.wechat_nickname = [UILabel fk_labelWithFont:fkFont12 textColor:[UIColor fk_colorWithHexString:@"#333333"]];
    [self.contentView addSubview:self.wechat_nickname];
    self.wechat_nickname.numberOfLines = 0;
    [self.wechat_nickname mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.wechat_avator.mas_right).offset(fk_adjustW(8));
        make.height.offset(fk_adjustW(32));
        make.width.mas_equalTo(fk_adjustW(130));
        make.centerY.mas_equalTo(self.wechat_avator);
    }];
    
    self.nickname = [UILabel fk_labelWithFont:fkFont12 textColor:[UIColor fk_colorWithHexString:@"#333333"]];
    [self.contentView addSubview:self.nickname];
    self.nickname.numberOfLines = 0;
    [self.nickname mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.wechat_nickname.mas_right).offset(fk_adjustW(20));
        make.height.mas_equalTo(self.wechat_nickname);
        make.width.mas_equalTo(fk_adjustW(55));
        make.centerY.mas_equalTo(self.wechat_nickname);
    }];
    
    self.phone = [UILabel fk_labelWithFont:fkFont12 textColor:[UIColor fk_colorWithHexString:@"#333333"]];
    [self.contentView addSubview:self.phone];
    [self.phone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.nickname.mas_right).offset(fk_adjustW(10));
        make.right.mas_equalTo(-10);
        make.centerY.mas_equalTo(self.nickname);
    }];
    
}

- (void)setData:(id)data
{
    [super setData:data];
    
    FKIncomeDetail *model = data;
    
    self.priceLabel.attributedText = model.priceStr;
    self.commissionLabel.text = model.commissionStr;
    self.dateLabel.text = model.timeStr;
    self.orderNoLabel.text = model.orderStr;
    self.tagLabel.text = model.orderType;
    self.statusLabel.text = model.statusName;
    self.statusLabel.backgroundColor = model.statusBgColor;
    
    [self.wechat_avator sd_setImageWithURL:[NSURL URLWithString:model.user[@"avatar"]] placeholderImage:kPlaceholder_1x1];
    self.wechat_nickname.text = model.user[@"nickname"];
    self.nickname.text = model.user[@"name"];
    self.phone.text = model.user[@"mobile"];
}

@end
